package com.demo.androidgame.samgukji_hit;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

import com.demo.androidgame.fx.gl.SpriteBatcher;

public class MusicStageUpdate{
	
	public static final int SCREEN_WIDTH = 800;
	public static final int SCREEN_HEIGHT = 480;
	
	Bow01 bow01;
	MusicUnit musicUnit;
	MusicNote musicNote;
	
	MusicStageRender musicStageRender;
	public float bowX, bowY, unitX;
	
	SpriteBatcher batcher;
	
	List<Bow01> bows01;
	List<MusicUnit> musicUnits;
	List<MusicNote> musicNotes;
	
	public MusicStageUpdate() {
		this.bows01 = new ArrayList<Bow01>();
		this.musicUnits = new ArrayList<MusicUnit>();
		this.musicNotes = new ArrayList<MusicNote>();
		addMusicUnit();
		addBow(bowX, bowY);
		bowX = 20;
		bowY = 0;
		bow01 = new Bow01(bowX, bowY);
		
		musicUnit = new MusicUnit(unitX, 390);
	}
	
	public void update(float deltaTime){
		//bows목록의 개별 bow항목 Update
		bow01.update(deltaTime);
		
		musicUnit.update(deltaTime);
	}
	
	public void addBow(float x, float y) {
		bow01 = new Bow01(x, y);
		//생성된 Bow를 List에 추가
		bows01.add(bow01);
	}
	
	public void addMusicUnit(){
		musicUnit = new MusicUnit(unitX, 390);
		musicUnits.add(musicUnit);
	}
	
	public void updateBow(float deltaTime){
		int len = bows01.size();
		for(int i = 0; i < len; i++){
			bow01 = bows01.get(i);
			bow01.update(deltaTime);
		}
	}
	
	public void updateMusicUnit(float deltaTime){
		int len = musicUnits.size();
		for(int i = 0; i < len; i++){
			if(i < 5){
			musicUnit = musicUnits.get(i);
			musicUnit.update(deltaTime);
			}
		}
	}
	
	public void bowDelete(){
		int len = bows01.size();
		for(int i = 1; i < len; i++){
			bow01 = bows01.get(i);
			if(bows01.get(i).position.x > SCREEN_WIDTH -200){
				bows01.remove(bow01);
				len = bows01.size();
			}	
		}		
	}
	
	

}
